package com.fingard.dsp.bank.reqrespobj.userinfo;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.userinfo.detail.RetAtsQryUserInfoDetail;
import com.fingard.xml.XmlTextWriter;

/**
 * 用户信息查询响应
 * 
 * @author Cruise
 * @date 2018年8月15日
 */
public class RetAtsQryUserInfo extends RetAtsBase {
	public String respCode;
	public String respInfo;
	
    public RetAtsQryUserInfo(ReqRespHeader tmpHeader) {
        retHeader = tmpHeader;
        retXmlWriter = new XmlTextWriter();
    }
    
    private int writeRdCount = 0;
    public int getWrittenRdCount() {
        return writeRdCount;
    }
    
    public RetAtsQryUserInfoDetail retDetail;
    public void writeRetDetail(RetAtsQryUserInfoDetail tmpRetDetail) throws Exception {
    	writeRdCount++;
        if (writeRdCount == 1) {
            if (!hasWrittenRespCode) {
                writeRespCode("0");
            }
            if (!hasWrittenRespInfo) {
                writeRespInfo("");
            }
        }
        
        retXmlWriter.writeStartElement("DetailRecord");
        tmpRetDetail.writeXE(retXmlWriter);
        retXmlWriter.writeEndElement();
    }
    
    private boolean hasWrittenBefore = false;
	public void writeBeforeDetail() throws Exception {
		if (hasWrittenBefore) {
			throw new Exception("writeBeforeDetail已被调用过");
		}
		writeStart();
		retXmlWriter.writeElementString("RespCode", respCode);
		retXmlWriter.writeElementString("RespInfo", respInfo);
		hasWrittenBefore = true;
	}

	public void writeAfterDetail() throws Exception {
		if (!hasWrittenBefore) {
			writeBeforeDetail();
		}
		writeEnd();
	}
}
